package com.lin.gulimall.search.controller;

import com.lin.gulimall.search.vo.SearchParam;
import com.lin.gulimall.search.service.MallSearchService;
import com.lin.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class Search {

    @Autowired
    MallSearchService mallSearchService;

    /*
    * 自动将页面提交过来的所有请求查询参数封装成指定的对象。
    *
    */
    @GetMapping("/list.html")
    public String listPage(SearchParam param, Model model){
        SearchResult result = mallSearchService.search(param);
        model.addAttribute("result");
        return "list";
    }
}
